package vsy.buzzwordbingo.model;

import java.util.List;

public interface GameCore {

	// ----- MANAGE PLAYERS -----

	/**
	 * The method trys to log in a player into the gamecore.
	 * @param player - a Player object containing id, name, password aso.
	 * @exception DuplicatePlayerException the exception is thrown<br>
	 * if the current Player is already logged in.
	 * */
	public void loginPlayer(Player player) throws DuplicatePlayerException;
	
	/**
	 * The method trys to log in a player into the gamecore. This method<br>
	 * differs from loginPlayer(Player player) to implement some additional<br>
	 * information which is needed to handle web-clients as well as <br>
	 * application based clients.
	 * @param name - a String representing the player name
	 * @param password - 
	 * @exception DuplicatePlayerException the exception is thrown<br>
	 * if the current player is already logged in.
	 * @exception IllegalArgumentException the exception is thrown<br>
	 * if the name String is empty or the password String<br>
	 * does not match the requirements.
	 * */
	public Player loginPlayer(String name, String password)
			throws DuplicatePlayerException, IllegalArgumentException;

	/**
	 * The method removes a player off the server. The Player<br>
	 * object is identified by a playerName String. During the<br>
	 * logout process all gameboards of the selected Player will<br>
	 * be deleted and all references to any active games of this<br>
	 * player will be unlinked.
	 * @param playerName - a String representing the name of the Player
	 * */
	public void logoutPlayer(String playerName);

	/**
	 * The method returns a generic java.util.List of Player objects.
	 * This list contains every player that is currently logged in.
	 * @return <b>List</b> - list of players currently logged in
	 * */
	public List<Player> getPlayers();

	/**
	 * The method is used for identifying a Player object by its playerName String.
	 * @param playerName - a String representing the player
	 * @return <b>Player</b> - returns the Player object that matches the current playerName
	 * */
	public Player getPlayer(String playerName);

	// ----- MANAGE GAMES -----

	/**
	 * The method is used for creating games. It needs a playerName<br>
	 * to identify which player creates this game, a title String,<br>
	 * a size as int and a java.util.List which contains the words<br>
	 * for this game. The size is the amount of rows/columns. Each<br>
	 * gameboard is squarish.
	 * @param playerName - a String that represents a Player object
	 * @param title - a String that is used as title of the game
	 * @param size - an int value between 3 and 10 -> amount of rows/columns
	 * @param description - a String that is used as a short description of the current game
	 * @param words - a generic List of Strings which contains the words for the game
	 * @return <b>Game</b> - the currently created game is returned
	 * */
	public Game createGame(String playerName, String title, int size,
			String description, List<String> words);

	/**
	 * The method identifies a game by its gameId and starts a thread-based cleanup.<br>
	 * During this cleanup all references to and all gameboards of this game will be deleted.
	 * @param gameId - a String used to identify a specific game
	 * */
	public void destroyGame(String gameId);

	/**
	 * Creates an ArrayList of all active games and returns it.<br>
	 * The list is of type java.util.List and uses generics.
	 * @return <b>List</b> - a generic list containing Game objects
	 * */
	public List<Game> getGames();

	/**
	 * The method returns the active game matching the given gameId.
	 * @return <b>Game</b> - game matching the gameId<br>
	 * <b>null</b> - none of the active games matches the given gameId
	 * */
	public Game getGame(String gameId);

	
	// ----- MANGE GAME/PLAYER MAPPINGS -----

	/**
	 * The method adds an existing player to an existing game.<br>
	 * Player and game are identified by the parameters gameId<br>
	 * and playerName. If the player joins this specific game for<br>
	 * the first time, a new gameboard is created, linked and returned.
	 * @param gameId - a String used for identifying a game
	 * @param playerName - a String used for identifying a player
	 * @return <b>GameBoard</b> - the new gameboard which has been<br>
	 * created during join game
	 * */
	public GameBoard joinGame(String gameId, String playerName);

	/**
	 * The method removes a Player, identified by its playerName,
	 * from a game, selected by its gameId.
	 * @param gameId - a String used for identifying a game
	 * @param playerName - a String used for identifying a play
	 * */
	public void leaveGame(String gameId, String playerName);

	/**
	 * The method identifies a game and a player to get the specific gameboard.<br>
	 * This specific gameboard is returned.
	 * @param gameId - a String used for identifying game
	 * @param playerName - a String used for identifying a player
	 * @return <b>GameBoard</b> - the explicit gameboard of the given player in<br>
	 * combination with the given game
	 * */
	public GameBoard getBoard(String gameId, String playerName);

	// ----- MANAGE BOARDS -----

	/**
	 * The method marks/unmarks the specified field on a gameboard. The gameboard is identified by
	 * the gameId in combination with the playerName who has marked/unmarked the field.
	 * If the field is marked or unmarked is decided by a boolean value named '<b>marked</b>'.
	 * @param gameId - is used to identify the gameboard on which the specified field is marked
	 * @param playerName - is used to identify the gameboard on which the specified field is marked
	 * @param row - identifies the row
	 * @param col - identifies the column
	 * @param marked - boolean value that declares if the selected field is marked oder unmarked
	 * @return damn its void!
	 * */
	public void markBuzzword(String gameId, String playerName, int row, int col,
			boolean marked);

	/**
	 * The method polls a game and keeps the player status as active.
	 * The activity status of a player is conducted by its gameboard
	 * because of the reason that a player can join multiple games.
	 * So the player can have different status' in different games. 
	 * @param gameId - is used to identify which gameboard is meant<br>
	 * @param playerName - identifies the player which is polling
	 * */
	public void poll(String gameId, String playerName);

	/**
	 * The method returns a specific gameboard, identified by its id.
	 * @param id - a String that represents a gameboard
	 * @return
	 * <b>GameBoard</b> - the selected gameboard<br>
	 * <b>null</b> - no active gameboard matches the id
	 * */
	public GameBoard getBoard(String id);

	/**
	 * The method returns a list of active gameboards.
	 * The list is of type java.util.list and uses Generics.<br>
	 * @return List<GameBoard> -  a list containing every gameboard
	 * */
	public List<GameBoard> getBoards();

}
